package com.hbms.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hbms.common.annotation.Log;
import com.hbms.common.core.controller.BaseController;
import com.hbms.common.core.domain.AjaxResult;
import com.hbms.common.enums.BusinessType;
import com.hbms.business.domain.HotelbmsUserhotelfavorites;
import com.hbms.business.service.IHotelbmsUserhotelfavoritesService;
import com.hbms.common.utils.poi.ExcelUtil;
import com.hbms.common.core.page.TableDataInfo;

/**
 * 用户收藏酒店Controller
 * 
 * @author zl
 * @date 2024-04-10
 */
@RestController
@RequestMapping("/business/userhotelfavorites")
public class HotelbmsUserhotelfavoritesController extends BaseController
{
    @Autowired
    private IHotelbmsUserhotelfavoritesService hotelbmsUserhotelfavoritesService;

    /**
     * 查询用户收藏酒店列表
     */
    @PreAuthorize("@ss.hasPermi('business:userhotelfavorites:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotelbmsUserhotelfavorites hotelbmsUserhotelfavorites)
    {
        startPage();
        List<HotelbmsUserhotelfavorites> list = hotelbmsUserhotelfavoritesService.selectHotelbmsUserhotelfavoritesList(hotelbmsUserhotelfavorites);
        return getDataTable(list);
    }

    /**
     * 导出用户收藏酒店列表
     */
    @PreAuthorize("@ss.hasPermi('business:userhotelfavorites:export')")
    @Log(title = "用户收藏酒店", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelbmsUserhotelfavorites hotelbmsUserhotelfavorites)
    {
        List<HotelbmsUserhotelfavorites> list = hotelbmsUserhotelfavoritesService.selectHotelbmsUserhotelfavoritesList(hotelbmsUserhotelfavorites);
        ExcelUtil<HotelbmsUserhotelfavorites> util = new ExcelUtil<HotelbmsUserhotelfavorites>(HotelbmsUserhotelfavorites.class);
        util.exportExcel(response, list, "用户收藏酒店数据");
    }

    /**
     * 获取用户收藏酒店详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:userhotelfavorites:query')")
    @GetMapping(value = "/{userHotelFavoriteId}")
    public AjaxResult getInfo(@PathVariable("userHotelFavoriteId") Long userHotelFavoriteId)
    {
        return success(hotelbmsUserhotelfavoritesService.selectHotelbmsUserhotelfavoritesByUserHotelFavoriteId(userHotelFavoriteId));
    }

    /**
     * 新增用户收藏酒店
     */
    @PreAuthorize("@ss.hasPermi('business:userhotelfavorites:add')")
    @Log(title = "用户收藏酒店", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelbmsUserhotelfavorites hotelbmsUserhotelfavorites)
    {
        return toAjax(hotelbmsUserhotelfavoritesService.insertHotelbmsUserhotelfavorites(hotelbmsUserhotelfavorites));
    }

    /**
     * 修改用户收藏酒店
     */
    @PreAuthorize("@ss.hasPermi('business:userhotelfavorites:edit')")
    @Log(title = "用户收藏酒店", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelbmsUserhotelfavorites hotelbmsUserhotelfavorites)
    {
        return toAjax(hotelbmsUserhotelfavoritesService.updateHotelbmsUserhotelfavorites(hotelbmsUserhotelfavorites));
    }

    /**
     * 删除用户收藏酒店
     */
    @PreAuthorize("@ss.hasPermi('business:userhotelfavorites:remove')")
    @Log(title = "用户收藏酒店", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userHotelFavoriteIds}")
    public AjaxResult remove(@PathVariable Long[] userHotelFavoriteIds)
    {
        return toAjax(hotelbmsUserhotelfavoritesService.deleteHotelbmsUserhotelfavoritesByUserHotelFavoriteIds(userHotelFavoriteIds));
    }
}
